package com.yb.domain.goods;

import java.util.List;

import com.yb.base.annotation.Column;
import com.yb.base.annotation.Table;
import com.yb.base.entity.BaseEntity;
import com.yb.bussiness.goods.CategoryService;
import com.yb.bussiness.goods.CategoryServiceImpl;

// default package

/**
 * TgCategory entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@Table("t_g_category")
public class TgCategory extends BaseEntity implements java.io.Serializable {

	// Fields

	private String level;
	private String name;
	private Integer pid;
	private String goodsDesc;
	private String goodsOrder;
	private String code;
	@Column(name = "reject")
	private List<TgCategory> children;
	@Column(name = "reject")
	private Integer count;// 总的拼购人数
	@Column(name = "reject")
	private Integer informationCount;

	public Integer getInformationCount() {
		if ("0".equals(level) && null == informationCount) {
			CategoryService service = new CategoryServiceImpl();
			informationCount = service.getTotalInfoByCategoryIdTask(this.getId());
		}
		return informationCount;
	}

	public void setInformationCount(Integer informationCount) {
		this.informationCount = informationCount;
	}

	public List<TgCategory> getChildren() {
		if ("0".equals(level) && null == children) {
			CategoryService service = new CategoryServiceImpl();
			children = service.findByPid(getId(), -1, -1);
		}
		return children;
	}

	public void setChildren(List<TgCategory> children) {
		this.children = children;
	}

	public String getLevel() {
		return this.level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getPid() {
		return this.pid;
	}

	public void setPid(Integer pid) {
		this.pid = pid;
	}

	public String getGoodsDesc() {
		return this.goodsDesc;
	}

	public void setGoodsDesc(String goodsDesc) {
		this.goodsDesc = goodsDesc;
	}

	public String getGoodsOrder() {
		return this.goodsOrder;
	}

	public void setGoodsOrder(String goodsOrder) {
		this.goodsOrder = goodsOrder;
	}

	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Integer getCount() {
		if ("0".equals(level) && null == count) {
			CategoryService service = new CategoryServiceImpl();
			count = service.getPingouCountByCategoryId(this.getId());
		}
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

}